package com.wngbms._04_classloader;

import java.util.Base64;

public class HelloClassLoader extends ClassLoader {

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
        Class<?> aClass = new HelloClassLoader().findClass("com.wngbms._04_classloader.Hello");
        aClass.newInstance();
    }

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        byte[] decode = decode(base64);
        return defineClass(name, decode, 0, decode.length);
    }

    public static byte[] decode(String base64) {
        return Base64.getDecoder().decode(base64);
    }

    public static String base64 = "yv66vgAAADQAHwoABgARCQASABMIABQKABUAFgcAFwcAGAEABjxpbml0PgEAAygpVgEABENvZGUBAA9MaW5lTnVtYmVyVGFibGUBABJMb2NhbFZhcmlhYmxlVGFibGUBAAR0aGlzAQAiTGNvbS93bmdibXMvXzA0X2NsYXNzbG9hZGVyL0hlbGxvOwEACDxjbGluaXQ+AQAKU291cmNlRmlsZQEACkhlbGxvLmphdmEMAAcACAcAGQwAGgAbAQAQbG9hZCBIZWxsbyBjbGFzcwcAHAwAHQAeAQAgY29tL3duZ2Jtcy9fMDRfY2xhc3Nsb2FkZXIvSGVsbG8BABBqYXZhL2xhbmcvT2JqZWN0AQAQamF2YS9sYW5nL1N5c3RlbQEAA291dAEAFUxqYXZhL2lvL1ByaW50U3RyZWFtOwEAE2phdmEvaW8vUHJpbnRTdHJlYW0BAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWACEABQAGAAAAAAACAAEABwAIAAEACQAAAC8AAQABAAAABSq3AAGxAAAAAgAKAAAABgABAAAAAwALAAAADAABAAAABQAMAA0AAAAIAA4ACAABAAkAAAAlAAIAAAAAAAmyAAISA7YABLEAAAABAAoAAAAKAAIAAAAGAAgABwABAA8AAAACABA=";
}
